#!/bin/bash

backupdir=../backup
lastbuildnum=$(ls $backupdir/ | cut -d. -f3 | sort -n | tail -1)
buildnum=$(($lastbuildnum + 1))
backupfn=$(date +backup.%Y-%m-%d.$buildnum)

tar cf $backupdir/$backupfn.tar .hg
cd $backupdir
zip -e $backupfn.tar.zip.tmp $backupfn.tar
mv -f $backupfn.tar.zip.tmp $backupfn.tar.zip
rm -f $backupfn.tar
ls -alF $backupfn.tar.zip

